<template>
  <div>
    <div id="normalBar" ref="normalBar" style="height:145px;margin-bottom:16px;"></div>
  </div>
</template>

<script>
import echarts from 'echarts'
export default {
  name: 'NormalBar',
  data () {
    return {
      mychart: {}
    }
  },
  mounted () {
    this.initChart()
    window.addEventListener('resize', () => {
      setTimeout(() => {
        this.mychart.resize()
      }, 500)
    })
  },
  methods: {
    initChart () {
      this.mychart = echarts.init(this.$refs.normalBar)
      const option = {
        backgroundColor: 'rgb(12,16,61)',
        color: ['#3cefff'],
        tooltip: {},
        grid: {
          top: 15,
          left: 0,
          right: 0,
          bottom: 0,
          containLabel: true
        },
        xAxis: [
          {
            type: 'category',
            data: ['坞城', '北营', '营盘', '小店', '平阳', '黄陵', '北格', '西温庄', '刘家堡'],
            axisTick: {
              alignWithLabel: true
            },
            nameTextStyle: {
              color: '#82b0ec'
            },
            axisLine: {
              lineStyle: {
                color: '#82b0ec'
              }
            },
            axisLabel: {
              textStyle: {
                color: '#82b0ec'
              }
            }
          }
        ],
        yAxis: [
          {
            type: 'value',
            axisLabel: {
              textStyle: {
                color: '#82b0ec'
              },
              formatter: '{value}'
            },
            splitLine: {
              lineStyle: {
                color: '#0c2c5a'
              }
            },
            axisLine: {
              show: true
            }
          }
        ],
        series: [
          {
            type: 'bar',
            itemStyle: {
              normal: {
                opacity: 0.7
              }
            },
            label: {
              show: true,
              position: 'top',
              color: '#fff'
            },
            barWidth: '10',
            data: [60, 70, 80, 90, 60, 70, 80, 90, 110]
          }
        ]
      }
      this.mychart.setOption(option)
    }
  }
}
</script>

<style lang="less" scoped></style>
